package com.shujia.wyh;

import com.shujia.wyh.utils.MysqlTool;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class JDBCTest6 {
    public static void main(String[] args) throws Exception {
        //获取数据库连接对象
        Connection conn = MysqlTool.getConnection();

        //获取预编译数据库操作对象
        PreparedStatement pps = conn.prepareStatement("select name,password from users where name like ?");

        pps.setString(1,"小%");

        ResultSet resultSet = pps.executeQuery();
        while (resultSet.next()){
            String name = resultSet.getString(1);
            String password = resultSet.getString(2);
            System.out.println(name+"--"+password);
        }

        pps.close();
        conn.close();
    }
}
